import $ from '../common';
Page({
  data: {
    active: 0,
    option:[],
    optionone:['目标','特色环节','活动流程'],
    optiontwo:['考试说明','考试须知','证书预览'],
    optionfour:['详细介绍','组织结构','规则','委会成员简介'],
  },
  onChange(event) {
    wx.showToast({
      title: `切换到标签 ${event.detail.name}`,
      icon: 'none',
    });
  },
  onLoad(e) {
    const {type='',name='',uuid=''}=e
    let tit=''
    let arr=[]
    tit=name
    if(type==4)tit='赛事详情'
    wx.setNavigationBarTitle({
      title: tit,
    })
    if(type==1)arr=this.data.optionone
    if(type==2)arr=this.data.optiontwo
    if(type==4)arr=this.data.optionfour
    this.setData({
      option:arr,
      uuid,
      type,
      zonecode:wx.getStorageSync('addresscode')||''
    })
    this.getinfo()
  },
  onShow() {},
  // 获取赛事详情
  getinfo(){
    const{zonecode,uuid,type}=this.data
    let url
    console.log(type);
    if(type==1)url='/socialprac/detail'
    if(type==2)url='/leveltest/detail'
    if(type==3)url='/studytrain/detail'
    if(type==4)url='/competition/detail'
    $.get(url,{
      zonecode,uuid
    },res=>{
      let data=[]
      if(type==1)data=res.socialprac
      if(type==2)data=res.leveltest
      if(type==3)data=res.studytrain
      if(type==4)data=res.competition
      this.setData({
        info:data
      })
    })
  },
  onReachBottom() {},
  onShareAppMessage() {}
})